using UnityEngine;
using UnityEngine.UI;
using HBFramework;
using UnityEngine.EventSystems;
using DG.Tweening;

public class ButtonAnimComp
{
    private GameObject gameObject;
    private Vector3 orginScale;

    public ButtonAnimComp(Button button)
    {
        var image = button.GetComponent<Image>();
        gameObject = image.gameObject;
        orginScale = gameObject.transform.localScale;
        image.OnPointerDown(OnImagePointerDown);
        image.OnPointerUp(OnImagePointerUp);
    }

    private void OnImagePointerDown(PointerEventData data)
    {
        var scale = orginScale * .9f;
        gameObject.transform.DOScale(scale, .2f).SetUpdate(true);
    }

    private void OnImagePointerUp(PointerEventData data)
    {
        gameObject.transform.DOScale(orginScale, .2f).SetUpdate(true);
    }
}
